<% content_for :sidebar do %>
  <%= sidebar_button_link 'New Item', new_item_path if can? :create, Item %>
<% end %>

<table id="items" class="datatable table table-striped table-bordered" >
  <caption><h3><%= @page_title %></h3></caption>
  <thead>
    <tr>
      <th>Name</th>
      <th>Qty</th>
      <th>Model</th>
      <th>Item Type</th>
      <th>Location</th>
      <th>Status</th>
      <th>Condition</th>
      <th></th>
    </tr>
  </thead>
  <tbody>
    <% @items.each do |item| %>
      <tr>
        <td><%= link_to item.name, item_path(item) %></td>
        <td><%= item.qty %></td>
        <td><%= "#{item.brand} #{item.model}" %></td>
        <td><%= item.item_type %></td>
        <td><%= item.location_name %></td>
        <td><%= item_status_label(item) %></td>
        <td><%= item_condition_label(item) %></td>
        <td><%= table_button_link 'Edit', edit_item_path(item) unless cannot? :edit, item %></td>
      </tr>
    <% end %>
  </tbody>
</table>
